{% extends "base.html" %}
{% load thumbnail %}
{% load mnav %}

{% block title %}{{ show.name }}{% endblock %}

{% block jscript %}
$(document).ready(function() 
    { 
        $("#episodeTable").tablesorter(); 
    } 
); 
{% endblock %}

{% block content %}
<div class="box">
    <a href="{{ MEDIA_URL }}{{ show.banner_filename }}"><img src="{% thumbnail show.banner_filename 758x140 %}"></a>

</div>
<div class="container">
<div class="span-6">
    <div class="box">
        <a href="{{ MEDIA_URL }}{{ show.poster_filename }}"><img src="{% thumbnail show.poster_filename 170x250 %}"></a>
    </div>
</div>
<div class="span-14 last">
    <h2>{{ show.name }}</h2>
    <p>{{ show.overview }}</p>
</div>
</div>
<h3>Episode List</h3>
<button onclick='$("#episodeForm").toggleCheckboxes();'>Toggle All</button>
<button onclick='$("#episodeForm").checkCheckboxes();'>Check All</button>
<button onclick='$("#episodeForm").unCheckCheckboxes();'>Uncheck All</button>
<form id="episodeForm" method="post">
<table id="episodeTable">
    <thead>
    <tr>
        <th align=left>Seen</th>
        <th align=left>NZB</th>
        <th align=left>Ep#</th>
        <th align=left>Airdate</th>
        <th align=left>Name</th>
        <th align=left>Dur</th>
        <th align=left>Size</th>
        <th align=left>Format</th>
    </tr>
    </thead>
    <tbody>
{% for episode in episodes %}
    <tr class="{% cycle "odd" "even" %}">
        <td><input type="checkbox" name="seen" value="{{episode.id}}" {% if episode.seen %}checked{% endif %} /></td>
        <td><a href="{{ episode.newzbin_url }}"><img width="15" height="15" src="{{ MEDIA_URL }}img/tv/logo/newzbin18.png"></a></td>
        <td>{{ episode.season_number }}x{{ episode.episode_number }}</td>
        <td>{{ episode.first_aired }}</td>
        <td><a href="{% url tv.views.episode_detail episode_id=episode.id %}">{{ episode.name }}</a></td>
        <td> {% for v in episode.tvvideofile_set.all %} <small>{{ v.general_duration|msecs_to_string }}</small><br> {% endfor %} </td>
        <td> {% for v in episode.tvvideofile_set.all %} <small>{{ v.file_size|bytes_to_string }}</small><br> {% endfor %} </td>
        <td> {% for v in episode.tvvideofile_set.all %} <small>{{ v.format_name }} - {{ v.audio_bitrate }} </small><br> {% endfor %} </td>
    </tr>
{% endfor %}
    </tbody>
</table>
<input type="Submit" value="Update Watched Episodes" />
</form>
{% endblock %}
